const Promise = require("./then");

let fs = require("fs");

function read(url){
    let dfd = Promise.defer();

    fs.readFile(url,'utf-8',function(err, data){
        if(err) dfd.reject(err);
        dfd.resolve(data);
    });

    return dfd.promise;
}

read('./txt/a.txt').then(res => {
    console.log(res);
},err => {
    console.log(err);
});